package nature.nano.util.provider;

import nature.nano.component.EmptyProps;
import nature.nano.component.Strings;
import nature.nano.environment.Config;
import nature.nano.iface.Accepter;
import nature.nano.component.PrimaryProvider;
import nature.nano.control.script.run.MetaRunner;

public class EnvironmentChecker extends PrimaryProvider {

	@Override
	public void start() {
		Accepter accepter = slot(Strings.error);
		accepter.onBegin(Strings.root, EmptyProps.instance);
		
		if (!Config.current().isLoadBasePropsSucceeded()) {
			error(
				Strings.error,
				Strings.errorType, "can't-load-basic-property-file",
				Strings.folder, Config.current().getBasePath(),
				Strings.file, "nanostream.properties");		
		} else {
			output(
				Strings.message,
				Strings.message, "basic-property-file-loaded",
				Strings.folder, Config.current().getBasePath(),
				Strings.file, "nanostream.properties");					
		}
		
		if (!Config.current().isLoadBasePropsSucceeded()) {
			error(
				Strings.error,
				Strings.errorType, "can't-load-default-values-file",
				Strings.file, Config.current().getProp(Strings.defaultValuesFile));		
		} else {
			output(
				Strings.message,
				Strings.message, "default-values-file-loaded",
				Strings.file, Config.current().getProp(Strings.defaultValuesFile));		
		}
		
		accepter.onEnd(Strings.root);
	}

	public static void main(String[] args) {
		MetaRunner.run("EnvironmentChecker.error > Printer");
	}
	
}
